import React, { Component } from 'react';

import "../../styles/worthbuying/MyGoodsList.css"
// 引入请求
import { IndexGoods } from "../../api/worthbuying"
class MyGoodsList extends Component {
    constructor(props) {
        super(props)
        this.state = {
            goods: []
        }
    }

    componentDidMount() {
        IndexGoods({ page: 1, count: 10 }).then((res) => {
            console.log(res.data.list);
            this.setState({ goods: res.data.list })
        })
    }

    render() {
        return (
            <div>
                <div className='goodslist'>
                    {
                        this.state.goods.map((item) => {
                            return (
                                <div className='goods' key={item.id} >
                                    <img src={item.pic} alt="" />
                                    <p className='text'>{item.name}</p>
                                    <p className='price'>抢购价¥<span>{item.salesPrice.value}</span></p>
                                </div>
                            )
                        })
                    }
                </div>
                <div className='down'></div>
            </div>

        );
    }
}

export default MyGoodsList;